import ddddocr
import os
import cv2

det = ddddocr.DdddOcr(det=False,ocr=False)
path = lambda x:os.path.join(os.path.dirname(__file__),'data/slide',x)

with open(path('2_0.jpg'),'rb') as f:
    background = f.read()

with open(path('2_1.png'),'rb') as f:
    slide = f.read()
res = det.slide_match(slide,background)['target']
pos1,pos2= [tuple(res[i:(i+2)]) for i in range(0,len(res),2)]
# 文本框标注
img = cv2.imread(path('2_0.jpg'))
img = cv2.rectangle(img,pos1,pos2,color=(0,0,255),thickness=2)
cv2.imshow('slide_note',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
cv2.imwrite(path('2_2.png'),img)
print(res)